<link rel="stylesheet" href="__STATIC__/lib/index/layui/css/layui.css" />
<div class="findtrs">
    <div class="ftitle">
        <div class="lt">
            <h2>快速开卡</h2>
        </div>
    </div>
    <div class="fkaicard fbai">
        <div class="ti">
            <h5>选择卡段<i>*</i></h5>
            <h6>（该卡段：发卡地美国/Regions Bank银行发行/Credit card/支持AVS地址验证/支持全球地区消费/卡片最低充值10美金）</h6>
        </div>
        <div class="fcardhao">
            <ul>
                {foreach $card_array as $v}
                    {if $v.is_used != 1}
                        {if $v.card_type == $default_card}
                            <li class="on">
                        {else}
                            <li>
                        {/if}
                        <a href="{:url('cards/index')}?c={$v.card_type}">
                            {if in_array($v.card_type , $cards_p616)}
                                {if $is_open_p616 != 1}
                                    <h5 style="background-color: #6c757d;color: #e5e5e5">维护</h5>
                                {/if}
                            {/if}
                            {if in_array($v.card_type , $cards_w990)}
                                {if $is_open_w990 != 1}
                                    <h5 style="background-color: #6c757d;color: #e5e5e5">维护</h5>
                                {/if}
                            {/if}
                            {if !in_array($v.card_type , $cards_bank1)}
                                {if($bank_type == 3)}
                                    {if $is_open_bank3 != 1}
                                    <h5 style="background-color: #6c757d;color: #e5e5e5">维护</h5>
                                    {/if}
                                {/if}
                            {/if}
<!--                            <h5>{if $v.is_refe == 1}推荐{/if}</h5>-->
                            <div class="ic">
                                {if substr($v.card_type , 0 , 1) == 4}
                                <img src="__STATIC__/lib/index/images/fn24.png" alt="">
                                {else}
                                <img src="__STATIC__/lib/index/images/fn23.png" alt="">
                                {/if}
                            </div>
                            <h6>{$v.card_type}</h6>
                        </a>
                        </li>
                    {/if}
                {/foreach}
            </ul>
            <a href="#" class="sji" id="ftianj">默认地址</a>
        </div>
        <div class="mcmask" id="rz"></div>
        <div class="mcadtanc mcadtanc1" id="rz_detail">
            <div class="hd">
                <h2>默认地址</h2>
                <div class="icons icons_rz"></div>
            </div>
            <div class="bd">
                <div class="ul clearfix">
                    <div class="li">
                        <h4>街道地址<span>*</span></h4>
                        <input type="text" name="default_address" id="default_address" value="{$address_list.address ?? '134 haines st'}"
                               maxlength="30" class="txt" placeholder="请填写街道地址">
                    </div>
                    <div class="li">
                        <h4>城市<span>*</span></h4>
                        <input type="text" name="default_city" id="default_city" value="{$address_list.city ?? 'Nashua'}"
                               maxlength="30" class="txt" placeholder="请填写城市">
                    </div>
                    <div class="li">
                        <h4>州<span>*</span></h4>
                        <input type="text" name="default_state" id="default_state" value="{$address_list.state ?? 'NH'}"
                               maxlength="30" class="txt" placeholder="请填写州">
                    </div>
                    <div class="li">
                        <h4>邮编<span>*</span></h4>
                        <input type="text" name="default_zip" id="default_zip" value="{$address_list.zip ?? '03060'}"
                               maxlength="30" class="txt" placeholder="邮编">
                    </div>
                </div>
                <span style="color: red;font-weight: bold;font-size: 20px;">* 可提交并更新一份地址用来作为固定地址</span>
                <div class="umbtn umbtn1" id="rz_sub">立即更新</div>
            </div>
        </div>
        <div class="tj"><i>*</i>速卖通/阿里巴巴国际站/Facebook ads/亚马逊德国、英国、法国站</div>
        <form action="" method="post"  class="layui-form">
            <div class="list">
                <ul>
                    <li>
                        <label class="lab">First Name<i>*</i></label>
                        <div class="rt">
                            <input type="text" class="info card_form" name="first_name" lay-verify="required" lay-verType="tips" placeholder="请输入FirstName">
                        </div>
                    </li>
                    <li>
                        <label class="lab">Last Name<i>*</i></label>
                        <div class="rt">
                            <input type="text" class="info card_form" name="last_name" lay-verify="required" placeholder="请输入LastName" lay-verType="tips">
                        </div>
                    </li>
                    <li>
                        <label class="lab">Middle Name</label>
                        <div class="rt">
                            <input type="text" class="info card_form" name="middle_name" lay-verify="" placeholder="请输入MiddleName" lay-verType="tips">
                        </div>
                    </li>
                    <li>
                        <label class="lab">开卡数量<i>*</i></label>
                        <div class="rt">
                            <input type="text" class="info" name="card_num" id="card_num" maxlength="5"
                                   value="1" lay-verify="required|zint_cn" placeholder="请输入开卡数量" lay-verType="tips">
                        </div>
                    </li>
                    <li>
                        <label class="lab">充值金额<i>*（建议多充1-2刀）</i></label>
                        <div class="rt">
                            <h5>$</h5>
                            <input type="text" class="text card_form" name="spend_limit" id="spend_limit" maxlength="5"
                                   value="{$create_amount}" lay-verify="required|number_cn" placeholder="" lay-verType="tips">
                        </div>
                    </li>
                    <li>
                        <label class="lab">街道地址<i>*</i></label>
                        <div class="rt">
                            <input type="text" class="info card_form" value="{$address_list.address ?? '134 haines st'}"
                                   name="billing_address" lay-verify="required" placeholder="请输入街道地址" lay-verType="tips">
                        </div>
                    </li>
                    <li>
                        <label class="lab">城市<i>*</i></label>
                        <div class="rt">
                            <input type="text" class="info card_form" name="city" value="{$address_list.city ?? 'Nashua'}"
                                   lay-verify="required" placeholder="请输入城市" lay-verType="tips">
                        </div>
                    </li>
                    <li>
                        <label class="lab">州<i>*</i></label>
                        <div class="rt">
                            <input type="text" class="info card_form" name="state" value="{$address_list.state ?? 'NH'}"
                                   lay-verify="required" placeholder="请输入州(例:AL)" lay-verType="tips">
                        </div>
                    </li>
                    <li>
                        <label class="lab">邮编<i>*</i></label>
                        <div class="rt">
                            <input type="text" class="info card_form" name="zip" value="{$address_list.zip ?? '03060'}"
                                   lay-verify="required" placeholder="请输入邮编" lay-verType="tips">
                        </div>
                    </li>
                    <li>
                        <label class="lab">备注<i></i></label>
                        <div class="rt">
                            <input type="text" class="info card_form" name="remarks" value="" placeholder="请输入备注" >
                        </div>
                    </li>
                    <li>&nbsp;</li>
                    <li>&nbsp;</li>
                </ul>
            </div>
            <div class="fdetail">
                <ul>

                    <li style="font-size: 18px"><i>*</i>请输入英文地址、姓名，可以使用拼音；</li>
                    <li><i>*</i>当前卡段：1.卡费和服务费根据会员等级而定；2.货币转换费：非USD或者非美国本地商户的交易，每笔1%卡片余额实时扣除；</li>
                    <li><i>*</i>风控规则：对于已删卡仍然计算交易失败率，请谨慎用卡，避免账号被风控;</li>
                    <li><i>*费用明细：开卡费+充值金额+服务费</i></li>
                    <li><i>*总计金额必须大于账户余额才能开卡成功</i></li>
                    <li><i style="font-size: 18px">*总计：<span id="total_money_show">${$open_amount}+$<span id="text_amount">{$create_amount}</span>+$<span id="text_amount_server">{$create_amount*$server_amount}</span> = $ <span id="text_amount_total">{$open_amount + $create_amount + $create_amount*$server_amount}</span></span></i><br/></li>
                    <li><i style="font-size: 18px">*开卡中=>已开卡,预计1分钟内完成</i><span style="padding-left: 100px;font-weight: bold;font-size: 20px;">账户余额: $ {$user_balance}</span></li>
                </ul>
            </div>
            <div class="fbottonlst">
                <ul>
                    <input type="hidden" name="total_money_hide" id="total_money_hide" value="{$open_amount + $create_amount + $create_amount*$server_amount}"/>
                    <li><a href="#">清空</a></li>
                    <li class="on"><a href="#" lay-submit lay-filter="edit">开卡</a></li>
                </ul>
            </div>
            <input type="hidden" name="card_type" value="{$default_card}">
            <input type="hidden" name="bank_type" value="{$bank_type}">
        </form>
    </div>
</div>
<script>
	layui.use(['form'], function () {
		var form = layui.form;

		form.on('submit(edit)', function(data){
			var loading =layer.load(1, {shade: [0.1,'#fff']});
			JsPost("{:url('cards/index')}", data.field, function(res){
				layer.close(loading);
				if(res.code >0){
					layer.msg(res.msg, {time:1500}, function(){
						window.location.href = "{:url('cardList')}";
					});
				}else{
					layer.msg(res.msg , {time:1500});
				}
			})
		});
	});
</script>
<script>
    layui.use(['form','element'], function () {
        var form = layui.form,
            element = layui.element;

        $("#clear").click(function(){
            $(".card_form").val('');
            $("#fund_amount").val(10);
            $("#card_num").val(1);
        });

        $(function(){
            $('#spend_limit').keyup(function(){
                defaultShow();
            });

            $('#card_num').keyup(function(){
                defaultShow();
            });

            function defaultShow() {
                const fund_amount = $('#spend_limit').val();
                const card_num    = $('#card_num').val();
                if(card_num > 20){
                    layer.msg("每次最多能建20张卡." , {time:1500});
                    return false;
                }
                const open_card_amount = "{$open_amount}";
                const server_amount = "{$server_amount}";
                var total_money = (parseFloat(open_card_amount)
                    + parseFloat(fund_amount) + parseFloat(fund_amount)*parseFloat(server_amount)) * parseFloat(card_num);
                var total_money = total_money.toFixed(4);
                var total_money = parseFloat(total_money);
                $("#total_money_show").text("($" + open_card_amount + " + " +
                    "$" + fund_amount + " + " +
                    "$(" + fund_amount + " * " + server_amount + ")) * " + card_num +
                    " = $ " + total_money);
                $("#total_money_hide").val(total_money);
                if(fund_amount<=0){
                    $("#total_money_show").text('0.00');
                    $("#total_money_hide").val('0.00');
                }
            }
            function toFixed(num, s) {
                var times = Math.pow(10, s)
                var des = num * times + 0.5
                des = parseInt(des, 10) / times
                return des + ''
            }
        })
    });

    $('#ftianj').click(function(){
        $('#rz').show();
        $('#rz_detail').show();
    })
    $('.mcadtanc .icons_rz').click(function(){
        $('#rz').hide();
        $('#rz_detail').hide();
    })
    $(document).on('click', '#rz_sub', function () {
        var default_address = $("#default_address").val();
        var default_city    = $("#default_city").val();
        var default_state   = $("#default_state").val();
        var default_zip     = $("#default_zip").val();
        if(default_address == ''){
            layer.msg('address不能为空.' , {time:1500});
            return false;
        }
        if(default_city == ''){
            layer.msg('City不能为空.' , {time:1500});
            return false;
        }
        if(default_state == ''){
            layer.msg('state不能为空.' , {time:1500});
            return false;
        }
        if(default_zip == ''){
            layer.msg('zip不能为空.' , {time:1500});
            return false;
        }
        var index = layer.load(1, {shade: [0.1, '#fff']});
        JsPost('{:url("changeAddress")}', {
            default_address:default_address,
            default_city:default_city,
            default_state:default_state,
            default_zip:default_zip
        },function (re) {
            layer.close(index);
            if(re.code >0){
                layer.msg(re.msg , {time:1500});
                window.location.href = "{:url('index')}";
            }else{
                layer.msg(re.msg, {time:1500});
            }
        });
    });
</script>